package cn.edu.zafu.bigdata.mahuilin;

public abstract class Shape {
    // 抽象方法，用于计算形状的面积
    public abstract double area();

    // 抽象方法，用于计算形状的周长
    public abstract double perimeter();

    // final方法，用于打印形状的类型、面积和周长
    public final void display() {
        System.out.println("Shape Type: " + this.getClass().getSimpleName());
        System.out.println("Area: " + area());
        System.out.println("Perimeter: " + perimeter());
    }
}

class Circle extends Shape {
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double area() {
        return Math.PI * radius * radius;
    }

    @Override
    public double perimeter() {
        return 2 * Math.PI * radius;
    }
}

class Rectangle extends Shape {
    private double length;
    private double width;

    public Rectangle(double length, double width) {
        this.length = length;
        this.width = width;
    }

    @Override
    public double area() {
        return length * width;
    }

    @Override
    public double perimeter() {
        return 2 * (length + width);
    }
}

class TestShape {
    public static void main(String[] args) {
        Circle circle = new Circle(5.0);
        Rectangle rectangle = new Rectangle(4.0, 6.0);

        circle.display();
        rectangle.display();
    }
}

class FinalClass {
    // 类的内容
}

// 尝试继承FinalClass
class SubClass extends FinalClass {
    // 这将导致编译错误，因为FinalClass是final的
}

class ParentClass {
    public void display() {
        System.out.println("Parent display method");
    }
}

class ChildClass extends ParentClass {
    // 尝试重写display方法
    @Override
    public void display() {
        System.out.println("Child display method");
        // 这将导致编译错误，因为display方法是final的
    }
}

class FinalVariableDemo {
    public static void main(String[] args) {
        final int number = 10;
        // number = 20; // 这将导致编译错误，因为number是final的，不能被修改
    }
}